<?php
$this->breadcrumbs=array(
	'Kit News Articles'=>array('index'),
	'Create',
);

$this->menu=array(
	array('label'=>'List KitNewsArticle', 'url'=>array('index')),
	array('label'=>'Manage KitNewsArticle', 'url'=>array('admin')),
);
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'kit-news-article-form',
	'enableAjaxValidation'=>false,
)); ?>

	<?php //echo $form->errorSummary($model); ?>
    <div id="message"></div>

	<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>30,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'name'); ?>
	</div>
    
	<div class="row">
		<?php echo $form->labelEx($model,'active'); ?>
		<?php echo $form->checkBox($model,'active'); ?>
		<?php echo $form->error($model,'active'); ?>
	</div>

<?php $this->endWidget(); ?>
<div style="text-align: right;">
    <button type="button" class="button" onclick="$('#dialog').dialog('close');">Hủy</button>
    <button type="button" class="button" onclick="submitAjax('kit-news-article-form');">Submit</button>
</div>
</div><!-- form -->
<?php 
//$cs = Yii::app()->getClientScript();
//$cs->registerCoreScript('jquery');
?>
<script type="text/javascript">
function submitAjax(idForm) {
    var queryString = $('#'+idForm+'').serialize();
	if (queryString != '') {
		$.ajax({
            url: "<?php echo Yii::app()->createUrl('//news/backend/kitNewsArticle/create'); ?>",
            type: 'POST',
            data: queryString,
            dataType: 'json',
            success: function(data){
//                var obj = jQuery.parseJSON(data);
                if (data.type == 'success') {
                    //loadAjax('<?php echo Yii::app()->createUrl('//news/backend/kitNewsArticle/index'); ?>', '', 'ajax_result_list');
                    $.fn.yiiGridView.update('kit-news-article-grid');
                    $("#dialog").dialog("close");
                } else {
                    $("#message").html(data.message);
                }
            }
        });
	}
}
</script>
